<?php

App::uses('CrudController', 'Controller');
App::uses('Test', 'Model');

class ThemesController extends CrudController {

    public $_model = 'Theme';

    public function admin($testId) {
        $this->request->allowMethod('get');
        $this->loadModel('Test');
        $tests = $this->Test->getEnabled();
        $this->set('tests', $tests);
        $this->set('testId', $testId);
        $this->set('title', __('Temas'));
        $this->set('description', __('Administración'));
    }

    protected function getRecords($param) {
        $m = $this->_model;
        $records = $this->$m->getEnabledByTest($param);
        return $records;
    }

    protected function c($model) {
        return array(
            'test_id' => $model->test_id,
            'course' => mb_strtoupper(trim($model->course)),
            'theme' => mb_strtoupper(trim($model->theme)),
            'duration' => (int) $model->duration,
            'attendant' => mb_strtoupper(trim($model->attendant)),
            'type' => (int)$model->type,
        );
    }

    protected function u($model) {
        return array(
            'course' => mb_strtoupper(trim($model->course)),
            'theme' => mb_strtoupper(trim($model->theme)),
            'duration' => (int) $model->duration,
            'attendant' => mb_strtoupper(trim($model->attendant)),
            'type' => (int)$model->type,
        );
    }

}
